package models

import (
	"gorm.io/gorm"
	"learn-server/basic/config"
	"time"
)

type Class struct {
	Id           uint           `gorm:"column:id;type:bigint UNSIGNED;primaryKey;not null;" json:"id"`
	ClassName    string         `gorm:"column:class_name;type:varchar(255);not null;" json:"class_name"`
	ClassTeacher string         `gorm:"column:class_teacher;type:varchar(255);not null;" json:"class_teacher"`
	Price        uint           `gorm:"column:price;type:int UNSIGNED;not null;default:0;" json:"price"`
	ClassDesc    string         `gorm:"column:class_desc;type:varchar(255);comment:课程描述;not null;" json:"class_desc"`                        // 课程描述
	ClassStatus  uint           `gorm:"column:class_status;type:int;comment:课程状态： 1：未开始 2：进行中 3：已结束;not null;" json:"class_status"` // 课程状态： 1：未开始 2：进行中 3：已结束
	CreatedAt    time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt    time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt    gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (c *Class) TableName() string {
	return "class"
}
func (c *Class) GetClassList() (classList []*Class, err error) {
	err = config.DB.Find(&classList).Error
	return
}
